package com.ysy.wiki.controller;

import com.ysy.wiki.req.EbookQueryReq;
import com.ysy.wiki.req.EbookSaveReq;
import com.ysy.wiki.resp.CommonResp;
import com.ysy.wiki.resp.EbookResp;
import com.ysy.wiki.resp.PageResp;
import com.ysy.wiki.service.EbookService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/Ebook")
public class EbookController {


    @Resource
    private EbookService EbookService;

    @GetMapping("/list")
    public CommonResp list(@Valid  EbookQueryReq req){
        CommonResp<PageResp<EbookResp>> resp=new CommonResp<>();

        PageResp<EbookResp> list=EbookService.list(req);

        resp.setContent(list);
        return resp;
    }
    @PostMapping("/save")
    public CommonResp save(@Valid @RequestBody EbookSaveReq req){
        CommonResp resp=new CommonResp<>();
        EbookService.save(req);
        return resp;
    }
    @DeleteMapping("/delete/{id}")
    public CommonResp delete(@PathVariable Long id){
        CommonResp resp=new CommonResp<>();
        EbookService.delete(id);
        return resp;
    }

}

